Fix constructor binding when function has optional arguments - #375
Open
krystophny wants to merge 3 commits into
Open
Fix constructor binding when function has optional arguments#375krystophny wants to merge 3 commits into
krystophny wants to merge 3 commits into
Conversation
BindConstructorInterfaces marks constructor functions, and convert_derived_type_arguments then moves the ret_ return argument to the front. The lookup assumed the first optional argument is ret_, which fails with AssertionError when the constructor has user-defined optional arguments, since FunctionToSubroutineConverter inserts ret_ before the first optional argument. Find the ret_ argument by name instead. Fixes jameskermode#373
numpy 2.5 ships only manylinux_2_28 wheels, so the cp312 and cp313 Linux wheel builds fall back to compiling numpy from source inside the default manylinux2014 container, where gcc 10.2.1 fails numpy's 'requires GCC >= 10.3' check. Build in the manylinux_2_28 image, whose toolchain is new enough and where numpy wheels install directly.
Contributor
Author
|
Wheel CI failed for cp312/cp313 on Linux: numpy 2.5 ships only manylinux_2_28 wheels, so the default manylinux2014 container built numpy from source and failed its gcc >= 10.3 check. Included a one-line workflow fix building Linux wheels in the manylinux_2_28 image. |
The new example calls the constructor without its optional argument, which exposes the direct-c backend passing 0 instead of an absent pointer, so present() is true and the default branch never runs. Apply the direct-c optional-argument fix from jameskermode#370 so this PR is green independently; the changes are identical, so either merge order is clean.
Contributor
Author
|
The build (3.x) jobs failed in the direct-c pass: the new example calls the constructor without its optional argument, and on master the direct-c backend passes 0 instead of an absent pointer (#369), so present(scale) is true and the default branch never runs. Included the identical direct-c fix from #370 so this PR is green independently — either merge order is clean. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #373.
convert_derived_type_argumentslocates the auto-generatedret_return argument of afortranconstructorby taking the first argument with theoptionalattribute.FunctionToSubroutineConverterinsertsret_before the first optional argument, so when the constructor function has user-defined optional arguments the first optional is a user argument and the assertionsub.arguments[j].name[:4]=='ret_'fires. Find theret_argument by name prefix instead.Adds
examples/issue373_optional_constructorcovering theinterface widget_tconstructor idiom with an optional argument, both present and absent.Verification
Test fails on main
Test passes after fix
Unit tests (
pytest test/): 38 passed; the 2 pre-existingtest_parse_dnadfailures (missingtest/samples/DNAD.fpp) are addressed separately. Related examples (keep_single_interface,interface,derivedtypes,fortran_oo,extends) all pass.@jameskermode ready for review.